<?php

namespace app\common\model;

use think\Model;
use app\common\model\Base;

class OrderService extends Base {

    public function getTypeTextAttr($value, $data) {

        return $data['type'] == 1 ? '退货' : '换货';
    }

    public function getStatusTextAttr($value, $data) {

        if ($data['status'] == 0) {
            return '待处理';
        } elseif ($data['status'] == 1) {
            return '处理中';
        } elseif ($data['status'] == 10) {
            return '处理完成';
        }elseif ($data['status'] == -1) {
            return '用户撤消';
        }
    }

    
    public function model_where($wheres = []){
        
        foreach ($wheres as $key => $value) {
            if (isset($value[1]))
                $this->where($key, $value[0], $value[1]);
            else
                $this->where($key, $value[0]);
        }
        
        $this->alias('a');
        
        $this->join('order_goods og', 'og.id = a.order_goods_id', 'LEFT');
        $this->join('member m', 'm.id = a.member_id', 'LEFT');
        
        $this->field('a.*,og.title as goods_title,og.price as goods_price,og.image as goods_image,m.nickname');
        
        return $this;
        
    }
    
}
